package cn.labelnet.android.roomdb.base.data.tables

import android.arch.persistence.room.ColumnInfo
import android.arch.persistence.room.Entity
import android.arch.persistence.room.ForeignKey
import android.arch.persistence.room.PrimaryKey

/**
 * Created by yuan on 02/08/2017.
 * book table
 * 注意：数据类型必须为其支持的类型
 */
@Entity(tableName = "book", foreignKeys = arrayOf(ForeignKey(entity = UserTable::class,
        parentColumns = arrayOf("u_id"),
        childColumns = arrayOf("user_id")))
)
data class BookTable(
        @ColumnInfo(name = "b_id")
        @PrimaryKey(autoGenerate = true)
        var id: Int = 0,
        @ColumnInfo(name = "b_name")
        var name: String = "",
        @ColumnInfo(name = "b_author")
        var author: String = "",
        @ColumnInfo(name = "b_price")
        var price: Double = 0.toDouble(),
        @ColumnInfo(name = "b_copyright")
        var copyright: String = "",
        @ColumnInfo(name = "b_status")
        var status: Int = 0,
        @ColumnInfo(name = "user_id")
        var userId: Int = 0
) {
    // 必须有公共构造方法
    constructor() : this(0)
}
